<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<jsp:include page="head.jsp" />

<!-- green header strip with login and my account links -->
	<div id="header-wrap" class="wrap">
		<div id="green-header" class="container">
			<div id="customer-links" class="pull-right">
				<% 
				String logoutbtn = null;
				if (session.getAttribute("username") == null){
					logoutbtn = "login";
						}
						else{
							
						logoutbtn = "logout";
				}
%>				
				<a href="<%=logoutbtn %>.jsp"><%=logoutbtn %></a>
				<a href="account.jsp">My Account</a>
				<a href="registration.jsp">Sign-Up</a>
			</div>
		</div>
	</div>
<!-- the row-end div is to take care of the floating issue -->
	<div class="row-end"></div>
<!-- This is the main content of the "page" 978px wide -->

	<header class="container">
	<div class="col3" id="logo">
		<img src="images/TravelLogo.jpg" alt="travel experts" />
	</div>
	<div class="col9" id="main-nav">
		<ul class="pull-right">
			<li><a href="index.jsp">Home</a></li>
			<li><a href="index.jsp">Packages</a></li>
			<li><a href="index.jsp">Specials</a></li>
			<li><a href="index.jsp">blog</a></li>
			<li><a href="index.jsp">Contact</a></li>
		</ul>
	</div>
	</header>
	<div class="row-end"></div>

<div id="main" role="main" class="container">
<h2>Hello <%=session.getAttribute("username") %></h2>
<div class="row-end"></div>
<div class="col8 first">
<% 
String fname = request.getParameter("uname");
String lname = request.getParameter("ulname");
String address = request.getParameter("uaddress");
String city = request.getParameter("ucity");
String prov = request.getParameter("uprov");
String postal = request.getParameter("upostal");
String country = request.getParameter("ucountry");
String homePhone = request.getParameter("uhomephone");
String busPhone = request.getParameter("ubusphone");
String un = request.getParameter("uemail");
String pw = request.getParameter("upasswd");
Connection conn = null;
PreparedStatement ps = null;
String sql = "Update Customers SET CustFirstName = ?, CustLastName = ?, CustAddress = ?, CustCity = ?, CustProv = ?, CustPostal = ?, CustCountry = ?, CustHomePhone = ?, CustBusPhone = ?, CustEmail = ?, CustPasswd = ? where CustEmail = ?";

//String sql = "Update Customers SET CustFirstName = ?, CustLastName = ?, CustAddress = ?, CustCity = ?, CustProv = [?], CustPostal = [?], CustCountry = [?], CustHomePhone = [?], CustBusPhone = [?], CustEmail = [?], CustPasswd = [?] where CustEmail= mike@medialounge.ca ";


try {
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/travelexperts","root","root");
	ps=conn.prepareStatement(sql);
	
	
	ps.setString(1, fname);
	ps.setString(2, lname);
	ps.setString(3, address);
	ps.setString(4, city);
	ps.setString(5, prov);
	ps.setString(6, postal);
	ps.setString(7, country);
	ps.setString(8, homePhone);
	ps.setString(9, busPhone);
	ps.setString(10, un);
	ps.setString(11, pw);
	ps.setString(12, un);
	ps.executeUpdate();
	
	response.sendRedirect("account.jsp");
	session.setAttribute("success","<h2>Information Updated Successfully.</h2>");

}catch(Exception e) {
e.printStackTrace();

	session.setAttribute("success","<h2>Information Was not updated.</h2>");
}
finally 
{
	conn.close();
	ps.close();
	}
%>
</div>
</div>
<!-- END Main -->
<!-- the row-end div is to take care of the floating issue -->
<div class="row-end"></div>
<div id="push"></div>
</div><!-- END OF Spacer -->
<jsp:include page="footer.jsp" />